/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.projet.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Oussama
 */
@Entity
@Table(name = "commande")
@XmlRootElement
@NamedQueries({
    //@NamedQuery(name="Commande.joincommande", query="SELECT c FROM Commande AS c  INNER JOIN FETCH c.idCommande" ),
    @NamedQuery(name = "Commande.findAll", query = "SELECT c FROM Commande c"),
    @NamedQuery(name = "Commande.findByIdCommande", query = "SELECT c FROM Commande c WHERE c.idCommande = :idCommande"),
    @NamedQuery(name = "Commande.findByMotDePasse", query = "SELECT c FROM Commande c WHERE c.motDePasse = :motDePasse"),
    @NamedQuery(name = "Commande.findByStatut", query = "SELECT c FROM Commande c WHERE c.statut = :statut"),
    @NamedQuery(name = "Commande.findByMtDPasse", query = "SELECT c FROM Commande c WHERE c.mtDPasse = :mtDPasse"),
    @NamedQuery(name = "Commande.findByDateLivraison", query = "SELECT c FROM Commande c WHERE c.dateLivraison = :dateLivraison"),
    @NamedQuery(name = "Commande.findByDatePaiement", query = "SELECT c FROM Commande c WHERE c.datePaiement = :datePaiement")})
public class Commande implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2147483647)
    @Column(name = "id_commande")
    private String idCommande;
    @Size(max = 2147483647)
    @Column(name = "mot_de_passe")
    private String motDePasse;
    @Size(max = 2147483647)
    @Column(name = "statut")
    private String statut;
    @Size(max = 2147483647)
    @Column(name = "mt_d_passe")
    private String mtDPasse;
    @Column(name = "date_livraison")
    @Temporal(TemporalType.DATE)
    private Date dateLivraison;
    @Column(name = "date_paiement")
    @Temporal(TemporalType.DATE)
    private Date datePaiement;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "commande")
    private List<ProduitCommande> produitCommandeList;

    public Commande() {
    }

    public Commande(String idCommande) {
        this.idCommande = idCommande;
    }

    public String getIdCommande() {
        return idCommande;
    }

    public void setIdCommande(String idCommande) {
        this.idCommande = idCommande;
    }

    public String getMotDePasse() {
        return motDePasse;
    }

    public void setMotDePasse(String motDePasse) {
        this.motDePasse = motDePasse;
    }

    public String getStatut() {
        return statut;
    }

    public void setStatut(String statut) {
        this.statut = statut;
    }

    public String getMtDPasse() {
        return mtDPasse;
    }

    public void setMtDPasse(String mtDPasse) {
        this.mtDPasse = mtDPasse;
    }

    public Date getDateLivraison() {
        return dateLivraison;
    }

    public void setDateLivraison(Date dateLivraison) {
        this.dateLivraison = dateLivraison;
    }

    public Date getDatePaiement() {
        return datePaiement;
    }

    public void setDatePaiement(Date datePaiement) {
        this.datePaiement = datePaiement;
    }

    @XmlTransient
    public List<ProduitCommande> getProduitCommandeList() {
        return produitCommandeList;
    }

    public void setProduitCommandeList(List<ProduitCommande> produitCommandeList) {
        this.produitCommandeList = produitCommandeList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCommande != null ? idCommande.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Commande)) {
            return false;
        }
        Commande other = (Commande) object;
        if ((this.idCommande == null && other.idCommande != null) || (this.idCommande != null && !this.idCommande.equals(other.idCommande))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.projet.entities.Commande[ idCommande=" + idCommande + " ]";
    }
    
}
